public class NumberValidation {

	public static void main(String[] args) {
		String text = "28";
		boolean valid = isValidInteger(text);
		System.out.printf("Is %s valid integer? %b\n", text, valid);
	
		text = "0.28";// NQMA DA MATCHNE
		valid = isValidInteger(text);
		System.out.printf("Is %s valid integer? %b\n", text, valid);
	
		text = "-1999";
		valid = isValidInteger(text);
		System.out.printf("Is %s valid integer? %b\n", text, valid);
	
		text = "01"; // NQMA DA MATCHNE
		valid = isValidInteger(text);
		System.out.printf("Is %s valid integer? %b\n", text, valid);
	
		text = "1hahaha23";
		valid = isValidInteger(text);
		System.out.printf("Is %s valid integer? %b\n", text, valid);
	
		text = "0";
		valid = isValidInteger(text);
		System.out.printf("Is %s valid integer? %b\n", text, valid);
	}
	
	private static boolean isValidInteger(String s) {
		String patternIntegerNumber = "0|[+-]?[1-9][0-9]*";
		boolean valid = s.matches(patternIntegerNumber);
		return valid;
	}
	
}
